 {% extends 'demo/base.html' %}
 {% load common_extras %}
 {% load static %}
 {% block title %}
    创作中心
{% endblock %}
 {% block link %}
    <link rel="stylesheet" href="{% static 'css/demo/nav.css' %}">
 {% endblock %}
 {% block header %}
    {% include 'demo/header.html' %}
 {% endblock %}
{% block main %}
    {% if articles %}
        <ul class="nav">
            {% for article in articles %}
                <li>
                    <a href="/demo/article/{{ article.id }}/">
                        <div class="left">
                            <h4>{{ forloop.counter }}、{{ article.title }}</h4>
                            <p>
                                {{ article.desc }}
                            </p>
                            <p class="time-info">发布时间：{{ article.create_time|date:"Y-m-d H:i:s" }}</p>
                        </div>
                        <div class="right">
                            <img src="{{ article.cover }}" alt="">
                        </div>
                    </a>
                    <div class="func">
                        <a href="#">修改</a>
                        <a href="#">删除</a>
                    </div>
                </li>
            {% endfor %}
            <div class="bottom_info">
                {% if pages.has_previous %}
                    <a href="{% url 'article_user' %}?page={{ pages.previous_page_number }}">上一页</a>
                {% endif %}
{#             通过循环显示多个页面的页码#}
                {% for page in pages.paginator.page_range %}
                    {% if page == pages.number %}
                         <a href="{% url 'article_user' %}?page={{ page }}"
                           style="border-bottom: 2px solid cornflowerblue">{{ page }}</a>
                         {% else %}
                         <a href="{% url 'article_user' %}?page={{ page }}">{{ page }}</a>
                    
                    {% endif %} 

                {% endfor %}
{#                判断是否有下一页#}
                {% if pages.has_next %}
                    <a href="{% url 'article_user' %}?page={{ pages.next_page_number }}">下一页</a>
                {% endif %}
                {% if not pages.has_next %}
                    <p>暂无更多文章</p>

                {% endif %}

            </div>
        </ul>
    {% endif %}

{% endblock %}